package com.zhang.crm.util;

import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.io.PrintWriter;

public class ResponseUtil {
    public static void write(HttpServletResponse req, String json) {
        req.setContentType("application/json;charset=utf-8");
        PrintWriter writer = null;
        try {
            writer = req.getWriter();
            writer.write(json);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            if (writer != null) {
                writer.flush();
                writer.close();
            }
        }

    }
}
